package com.tzbank.common.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tzbank.common.service.PushReqMsgService;
import com.tzbank.utils.ResultCode;
import com.tzbank.utils.ResultUtil;

@RestController
@RequestMapping("pushMsg")
public class PushReqMsgController {

	@Resource
	private PushReqMsgService pushReqMsgService;

	@PostMapping(value = "/add")
	public Map<String, Object> addPushReqMsg(@RequestBody Map<String, Object> reqBody) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		boolean res = pushReqMsgService.add(reqBody);
		if (res) {
			return ResultUtil.resultMap("成功", ResultCode.RESULT_CODE_SUCCESS.code(), resultMap);
		}
		return ResultUtil.resultMap("失败", ResultCode.RESUTL_CODE_FAILURE.code(), resultMap);
	}

	@PostMapping(value = "/update")
	public Map<String, Object> updatePushReqMsg(@RequestBody Map<String, Object> reqBody) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		boolean res = pushReqMsgService.updateReadStatusByMsgId(reqBody);
		if (res) {
			return ResultUtil.resultMap("成功", ResultCode.RESULT_CODE_SUCCESS.code(), resultMap);
		}
		return ResultUtil.resultMap("失败", ResultCode.RESUTL_CODE_FAILURE.code(), resultMap);
	}
}
